#ifndef HTTPMGR_H
#define HTTPMGR_H
#include "singleton.h"
#include <QString>
#include <QUrl>
#include <QObject>
#include <QNetworkAccessManager>
#include <QJsonObject>
#include <QJsonDocument>

/***************************************************************
* @file    httpmgr.h
* @brief   网络部分
*
* @author  轻语
* @date    2025/01/19
* @history
***************************************************************/

//CRTP
class HttpMgr:public QObject,public Singleton<HttpMgr>,public std::enable_shared_from_this<HttpMgr>
{
    Q_OBJECT
public:
    ~HttpMgr();
    void PostHttpReq(QUrl url,QJsonObject json,ReqId req_id,Modules modules);
private:
    friend class Singleton<HttpMgr>;
    HttpMgr();
    QNetworkAccessManager _manager;

private slots:
    void slots_http_finish(ReqId id,QString str,ErrorCodes err,Modules modules);
signals:
    void sig_http_finish(ReqId id,QString str,ErrorCodes err,Modules modules);
    void sig_reg_mod_finish(ReqId id,QString res,ErrorCodes err);//发信号让注册模块接受
    void sig_reset_mod_finish(ReqId id,QString res,ErrorCodes err);//发信号让忘记密码模块接受
    void sig_login_mod_finish(ReqId id,QString res,ErrorCodes err);//发信号让登录模块接受
};

#endif // HTTPMGR_H
